package com.demo.sso.service.impl;

import com.demo.sso.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    // 模拟用户数据库
    private static final String DEFAULT_USERNAME = "admin";
    private static final String DEFAULT_PASSWORD = "123456";

    @Override
    public boolean login(String username, String password) {
        // 实际项目中应查询数据库进行验证
        return DEFAULT_USERNAME.equals(username) && DEFAULT_PASSWORD.equals(password);
    }

    @Override
    public Object getUserByUsername(String username) {
        if (DEFAULT_USERNAME.equals(username)) {
            return new UserInfo(username, "系统管理员");
        }
        return null;
    }

    // 用户信息内部类
    private static class UserInfo {
        private String username;
        private String nickname;

        public UserInfo(String username, String nickname) {
            this.username = username;
            this.nickname = nickname;
        }

        // Getter方法
        public String getUsername() { return username; }
        public String getNickname() { return nickname; }
    }
}